﻿using System;
using System.Collections.Generic;


public class TimeUtils
{
    static private System.DateTime startTime;
    static private int timeId;
    static private System.Object lockObj;

    static TimeUtils()
    {
        lockObj = new object();
        startTime = new System.DateTime(1970, 1, 1);
    }

    public static double nowTime
    {
        get
        {
            TimeSpan ts = DateTime.UtcNow - startTime;
            return ts.TotalMilliseconds;     //精确到毫秒
        }
    }


    public static double nowSecTime
    {
        get
        {
            TimeSpan ts = DateTime.UtcNow - startTime;
            return ts.TotalSeconds;     //精确到秒
        }
    }

    static public int getTimeId()
    {
        lock (lockObj)
        {
            return ++timeId;
        }
    }

}

